﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Common;

namespace Bugtracker
{
    public abstract class Bugtracker
    {
        protected SettingsManager settings_ = null;

        private ProgressCallback progress_callback_ = null;

        public Bugtracker(SettingsManager settings)
        {
            settings_ = settings;
        }

        public void RegisterProgressCallback(ProgressCallback callback)
        {
            progress_callback_ = callback;
        }

        protected void UpdateProgress(String step, int currentStep, int totalStep)
        {
            if (progress_callback_ != null)
                progress_callback_(step, currentStep, totalStep);
        }

        public virtual bool ProjectExists(String project_name)
        {
            return GetProjectsList().Contains(project_name, new StringCaseInsensitive());
        }

        public abstract List<String> GetProjectsList();
        public abstract int ProjectAdd(String project_name, String project_description);
        public abstract void ProjectDelete(String project_name);
        public abstract void ProjectEdit(String old_project_name, String new_project_name, String project_description);

        public abstract List<String> GetSubProjectsList(String project_name);
        public abstract int SubProjectAdd(String parent_project_name, String project_name, String project_description);

        public virtual dsData.dtIssueDataDataTable GetIssuesList() { return GetIssuesList(String.Empty); }
        public virtual dsData.dtIssueDataDataTable GetIssuesList(String issue_status) { return GetIssuesList(String.Empty, issue_status); }
        public virtual dsData.dtIssueDataDataTable GetIssuesList(String project_name, String issue_status) { return GetIssuesList(project_name, String.Empty, issue_status); }
        public abstract dsData.dtIssueDataDataTable GetIssuesList(String project_name, String targeted_milestone, String issue_status);

        public abstract String IssueAdd();
        public abstract int IssueDelete();

        public abstract int IssueAttachmentAdd(String issue_id);
        public abstract int IssueAttachmentDelete(String issue_id);
        public abstract int IssueAttachmentGet(String issue_id);
        public abstract int IssueAttachmentView(String issue_id);
        public abstract int IssueAttachmentRename(String issue_id);

        public abstract int IssueNoteAdd(String issue_id);
        public abstract int IssueNoteDelete(String issue_id);
        public abstract int IssueNoteEdit(String issue_id);
    }
}
